<style src="../../style/contentTable.css" scoped></style>

<template>
    <div class="containerTable">
        <!--表3生产情况调查表T_VegProSurvey-->
        <Row  class="divSearch">
            <Col span="24" class="col-margin">
                <label class="searchLabel">县&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(市):</label>
                <Select v-model="searchModel.AreaCode"  placeholder="请选择..." style="width: 100px" @on-change="getPageData()">
                    <Option :value="userInfo.AreaCode">{{(userInfo.AreaCode=='530000000000')?'全省':'全市（州）'}}</Option>
                    <Option :value="item.value" v-for="item in AreaList" :key="item.value">{{item.label}}</Option>
                </Select>
            <!--<Cascader :data="AreaList" change-on-select @on-change='SearchCascaderChange' style="width: 200px;float: left;margin-right: 5px;"></Cascader>-->

            <!--根据需求删除不不要查询条件-->
            填报年度：
            <Select v-model="searchModel.FillInYear" placeholder="全部" style="width: 100px" @on-change="getPageData()">
                <Option value="">全部</Option>
                <Option :value="item.DictValue" v-for="item in CreateYearList" :key="item.DictValue">{{item.DictText}}</Option>
            </Select>
            <!--时间周期：
            <Select v-model="searchModel.TimesType" placeholder="全部" style="width: 100px" @on-change="getPageData()">
                <Option value="">全部</Option>
                <Option :value="item.DictValue" v-for="item in CycleList" :key="item.DictValue">{{item.DictText}}</Option>
            </Select>-->
            报表状态：
            <Select v-model="searchModel.Status" placeholder="全部" :label-in-value="true" @on-change="getPageData()" style="width:200px">
               <Option value="">全部</Option>
                <Option v-for="item in statusList" :value="item.DictValue" :key="item.DictValue">{{ item.DictText }}</Option>
            </Select>
            <Button icon="ios-search" type="ghost" @click="getPageData()">查询</Button>
            </Col>
        </Row>
        <Row>
            <Col span="24">
            <Table size="small" @on-select="selectSingel" @on-select-all="selectAll" :height="clientHeight" border :context="ctx" :columns="columnsList" :data="datas.rows" no-data-text='暂无数据...'></Table>
            </Col>
        </Row>
        <Row>
            <Col span="24">
            <Page class="page-style" :total="datas.total" placement="top" @on-change="getPageNumber" :page-size="searchModel.PageSize" :page-size-opts='pageSizeOpts' show-sizer @on-page-size-change="getPageSize" show-total show-elevator></Page>
            </Col>
        </Row>
        <!-- <Modal v-model="showType" :mask-closable="false" :closable="true" width="1200">
            <p slot="header" class="title">
                <Icon type="ios-paper" size="20"></Icon>
                <span style="font-size: 20px">生产情况调查表</span>
            </p>
            <p slot="close">
                <Icon type="close-circled" color="red" size=25></Icon>
            </p>
            <Tabs type="card" @on-click="getTab">
                <Tab-pane v-for="tabPane in TabTitleList" :label="tabPane.SortName" :name="tabPane.SortCode" :key="tabPane.SortName">
                    <div style="height:450px;overflow-y:auto">
                        <table class="reptable">
                            <tr>
                                <th rowspan="2" width="160px">品种</th>
                                <th rowspan="2">全年累计面积</th>
                                <th colspan="4">其中</th>
                                <th rowspan="2">全年累计产量</th>
                                <th rowspan="2">全年平均价格</th>
                            </tr>
                            <tr>
                                <th>当年新建果园</th>
                                <th>5年以下果园</th>
                                <th>5-20年果园</th>
                                <th>20年以上果园面积</th>
                            </tr>
                            <tr v-for="item in tabPane.list">
                                <td v-if="item.ItemName==item.SortSonName" style="padding-right: 5px;width:200px;text-align:right;">
                                    <b>{{item.ItemName}}</b</td>
                                        <td v-if="item.ItemName!=item.SortSonName" style="padding-right: 5px;width:200px;text-align:right;">
                                            <b>{{item.SortSonName}}</b>:{{item.ItemName}}</td>
                                        <td>
                                            <Input v-model="item.GrandArea"></Input>
                                        </td>
                                        <td>
                                            <Input v-model="item.NewArea"></Input>
                                        </td>
                                        <td>
                                            <Input v-model="item.FOrchard"></Input>
                                        </td>
                                        <td>
                                            <Input v-model="item.FTOrchard"></Input>
                                        </td>
                                        <td>
                                            <Input v-model="item.TOrchard"></Input>
                                        </td>
                                        <td>
                                            <Input v-model="item.CumYield"></Input>
                                        </td>
                                        <td>
                                            <Input v-model="item.AvgPrice"></Input>
                                        </td>
                            </tr>
                        </table>
                    </div>
                </Tab-pane>
            </Tabs>
            <div slot="footer">
                <div style="text-align:right;padding-top:5px">
                    <Button type="primary" @click="saveSure()">审核通过</Button>
                    <Button type="warning" @click="savenUnSure()">审核不通过</Button>
                    <Button type="ghost" @click="cancel()" style="margin-left: 5px">取消</Button>
                </div>
                <Alert style="margin-top:5px;text-align:left" banner type="error">
                    填报说明: 1.全省范围内从乡（镇）推广站起，逐级全面统计，由州（市）汇总后上报。
                    <br/> 2.统计面积中不含育苗面积。
                    <br/>幼年：树龄5年以下果园面积；盛果期：树龄5-20年果园面积；老果园：树龄20年以上果园面积
                    <br/>3. 水果分四个树龄阶段统计，各不互相包含；其中5年以下的，则不包含新植面积。
                    <span slot="desc">
                    </span>
                </Alert>
            </div>
        </Modal> -->
        <Modal v-model="showType" :mask-closable="false" :closable="true" width="1300" :styles="{top: '20px'}">
            <p slot="header" class="title">
                <Icon type="ios-paper" size="20"></Icon>
                <span style="font-size: 20px">{{ReportYear}}-{{AreaCodeName}}-主要水果生产情况年度面积产量表</span>
            </p>
            <p slot="close">
                <Icon type="close-circled" color="red" size=25></Icon>
            </p>
            <table class="ContentTable">
                <caption>                  
                  <label style="float:right">单位：
                      <span>亩、吨、吨/亩</span>                
                  </label>
                </caption>
                <thead>
                <tr>                  
                    <th  rowspan="2" >品种</th>
                    <th rowspan="2">全年累计面积</th>
                    <th rowspan="2" >全年累计产量</th>
                    <th rowspan="2" >平均亩产</th>
                    <th colspan="4" >其中</th>  
                    <th  rowspan="2" >备注</th>                                      
                </tr>
                <tr>
                    <th >当年新植果园面积</th>
                    <th >树龄5年以下果园面积</th>
                    <th >树龄5-20年果园面积</th>
                    <th >树龄20年以上果园面积</th>
                    </tr>
                </thead>
                <tbody>
                <tr v-for="(item,index) in list" :key="index">
                    <td v-if="item.ParentCode" style="text-align:right;">{{item.Variety}}</td> 
                    <td v-else style="font-weight:bold;">{{item.Variety}}</td>   
                                <td>                                        
                                    {{FormatBigNum(item.GrandArea)}}                                   
                                </td>
                                <td>
                                    {{FormatBigNum(item.CumYield)}}                                    
                                </td> 
                                <td>
                                    {{item.AvgMuYield}}                                   
                                </td> 
                                <td>
                                    {{FormatBigNum(item.NewArea)}}                                    
                                </td>
                                <td>
                                    {{FormatBigNum(item.FOrchard)}}                                    
                                </td>
                                <td>
                                    {{FormatBigNum(item.FTOrchard)}}                                    
                                </td>
                                <td>
                                    {{FormatBigNum(item.TOrchard)}}                                   
                                </td>
                                <td>
                                    {{item.Remark}}                                   
                                </td>
                                </tr>
                        </tbody>
                </table>            
            <div slot="footer" style="padding-bottom:50px">
                <div style="text-align:right;padding-top:5px">
                   <Button type="success" @click="toAlertCheckResult()" style="margin-right:50px">数据检测</Button>
                    <Button type="primary" @click="saveSure()">审核通过</Button>
                    <Button type="warning" @click="savenUnSure()">退回重报</Button>
                    <!--<Button type="ghost" @click="cancel()" style="margin-left: 5px">取消</Button>-->
                </div>
                <Alert style="margin-top:5px;text-align:left" banner type="error">
                    填报时间：每年1月10日</br>
                    填报说明: 1.全省范围内从乡（镇）起，逐级全面统计，由县级填报经州（市）审核后上报。
                    <br/> 2.统计面积中不含育苗面积。
                    <!-- <br/>幼年：树龄5年以下果园面积；盛果期：树龄5-20年果园面积；老果园：树龄20年以上果园面积 -->
                    <br/>3. 水果分四个树龄阶段统计，各不互相包含；其中5年以下的，则不包含新植面积;一年生水果不分树龄统计。                    
                    <span slot="desc">
                    </span>
                </Alert>
            </div>
        </Modal>
        <Modal v-model="showAudit" :mask-closable="false" width="500">
            <p slot="header" class="title">
                <Icon type="ios-paper" size="20"></Icon>
                <span style="font-size: 20px">退回重报原因</span>
            </p>
            <p slot="close">
                <Icon type="close-circled" color="red" size=25></Icon>
            </p>
            <Input type="textarea" :rows="4" v-model="strMsg" placeholder="请输入不通过原因..."></Input>
            <div slot="footer">
                <Button type="primary" @click="sureUnSure()">确定</Button>
                <Button type="ghost" @click="cancelUnSure()" style="margin-left: 8px">取消</Button>
            </div>
        </Modal>
        <!-- <Modal v-model="ViewShow" :mask-closable="false" width="1200">
            <p slot="header" class="title">
                <Icon type="ios-paper" size="20"></Icon>
                <span style="font-size: 20px">生产情况调查表</span>
            </p>
            <p slot="close">
                <Icon type="close-circled" color="red" size=25></Icon>
            </p>
            <table class="reptable" style="width:100%">
                <tr>
                    <th rowspan="2" style="width:101px;">树种</th>
                    <th rowspan="2" style="width:201px;">品种</th>
                    <th rowspan="2" style="width:100px;">全年累计面积</th>
                    <th colspan="4">其中</th>
                    <th rowspan="2" style="width:130px;">全年累计产量</th>
                    <th rowspan="2">全年平均价格</th>
                </tr>
                <tr>
                    <th style="width:100px;">当年新植果园</th>
                    <th style="width:100px;">5年以下果园</th>
                    <th style="width:100px;">5-20年果园</th>
                    <th style="width:140px;">20年以上果园面积</th>
                </tr>
            </table>
            <div class="reptablediv">
                <table v-for="tabPane in TabTitleList" class="infotable">
                    <tr>
                        <td style="width:100px;">{{tabPane.SortName}}</td>
                        <td>
                            <table class="infotable">
                                <tr v-for="item in tabPane.list">
                                    <td v-if="item.ItemName==item.SortSonName" style="padding-right: 5px;width:200px;text-align:right;">
                                        {{item.ItemName}}
                                    </td>
                                    <td v-if="item.ItemName!=item.SortSonName" style="padding-right: 5px;width:200px;text-align:right;">
                                        <b>{{item.SortSonName}}</b>:{{item.ItemName}}
                                    </td>
                                    <td style="width:100px;text-align:right;padding-right:10px;">{{item.GrandArea}}</td>
                                    <td style="width:100px;text-align:right;padding-right:10px;">{{item.NewArea}}</td>
                                    <td style="width:100px;text-align:right;padding-right:10px;">{{item.FOrchard}}</td>
                                    <td style="width:100px;text-align:right;padding-right:10px;">{{item.FTOrchard}}</td>
                                    <td style="width:140px;text-align:right;padding-right:10px;">{{item.TOrchard}}</td>
                                    <td style="width:130px;text-align:right;padding-right:10px;">{{item.CumYield}}</td>
                                    <td style="text-align:right;padding-right:10px;">{{item.AvgPrice}}</td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
                <br/>
            </div>
            <div slot="footer">
                <Alert style="margin-top:5px;text-align:left" banner type="error">
                    填报说明: 1.全省范围内从乡（镇）推广站起，逐级全面统计，由州（市）汇总后上报。
                    <span slot="desc">
                    </span>
                </Alert>
            </div>
        </Modal> -->
        <Modal v-model="ViewShow" :mask-closable="false" width="1300" :styles="{top: '20px'}">
            <p slot="header" class="title">
                <Icon type="ios-paper" size="20"></Icon>
                <span style="font-size: 20px">{{ReportYear}}-{{AreaCodeName}}-主要水果生产情况年度面积产量表</span>
            </p>
            <p slot="close">
                <Icon type="close-circled" color="red" size=25></Icon>
            </p>
            <table class="ContentTable">
                <caption>                  
                  <label style="float:right">单位：
                      <span>亩、吨、吨/亩</span>                
                  </label>
                </caption>
                <thead>
                <tr>                  
                    <th  rowspan="2" >品种</th>
                    <th rowspan="2">全年累计面积</th>
                    <th rowspan="2" >全年累计产量</th>
                    <th rowspan="2" >平均亩产</th>
                    <th colspan="4" >其中</th>  
                    <th  rowspan="2" >备注</th>                                      
                </tr>
                <tr>
                    <th >当年新植果园面积</th>
                    <th >树龄5年以下果园面积</th>
                    <th >树龄5-20年果园面积</th>
                    <th >树龄20年以上果园面积</th>
                    </tr>
                </thead>
                <tbody>
                <tr v-for="(item,index) in list" :key="index">
                    <td v-if="item.ParentCode" style="text-align:right;">{{item.Variety}}</td> 
                    <td v-else style="font-weight:bold;">{{item.Variety}}</td>   
                                <td>                                        
                                    {{FormatBigNum(item.GrandArea)}}                                   
                                </td>
                                <td>
                                    {{FormatBigNum(item.CumYield)}}                                    
                                </td> 
                                <td>
                                    {{item.AvgMuYield}}                                   
                                </td> 
                                <td>
                                    {{FormatBigNum(item.NewArea)}}                                    
                                </td>
                                <td>
                                    {{FormatBigNum(item.FOrchard)}}                                    
                                </td>
                                <td>
                                    {{FormatBigNum(item.FTOrchard)}}                                    
                                </td>
                                <td>
                                    {{FormatBigNum(item.TOrchard)}}                                   
                                </td>
                                <td>
                                    {{item.Remark}}                                   
                                </td>
                                </tr>
                        </tbody>
                </table>      
            <div slot="footer" style="padding-bottom:50px">
                <Alert style="margin-top:5px;text-align:left" banner type="error">
                    填报时间：每年1月10日</br>
                    填报说明: 1.全省范围内从乡（镇）起，逐级全面统计，由县级填报经州（市）审核后上报。
                    <br/> 2.统计面积中不含育苗面积。
                    <!-- <br/>幼年：树龄5年以下果园面积；盛果期：树龄5-20年果园面积；老果园：树龄20年以上果园面积 -->
                    <br/>3. 水果分四个树龄阶段统计，各不互相包含；其中5年以下的，则不包含新植面积;一年生水果不分树龄统计。                    
                    <span slot="desc">
                    </span>
                </Alert>
            </div>
        </Modal>
    </div>
</template>
<script>
export default {
  data() {
    return {
      list: [],
      ReportYear: "",
      AreaCodeName: "",
      ViewShow: false, //查看状态
      Id: "",
      showAudit: false,
      strMsg: "",
      userInfo: this.GetlocaStorage("fruuserinfo"),
      statusList: this.GetGroupDict("ReportStatus"),
      AreaList: [], //所属行政区划数组
      TableCodeList: this.GetGroupDict("ReportTableName"), //表名称
      CreateYearList: this.GetGroupDict("ReportYear"), //周期
      CycleList: this.GetGroupDict("ReportCycle"), //
      TabTitleList: [], //tab选项卡列表
      selectTabName: "",
      showType: false, //编辑框弹出状态
      ruleValidate: {
        //验证模型
        TableName: [{ required: true, message: "报表名称不能为空", trigger: "blur" }],
        TableCode: [{ required: true, message: "报表代码不能为空", trigger: "blur" }],
        CreateYear: [{ required: true, message: "年度不能为空", trigger: "blur" }],
        Cycle: [{ required: true, message: "时间周期不能为空", trigger: "blur" }],
        CreateTime: [{ required: true, message: "生成时间不能为空", trigger: "blur" }]
      },
      dataModel: {
        //编辑模型
        Id: 0,
        TableName: "",
        TableCode: "",
        CreateYear: "",
        Cycle: "",
        CreateTime: ""
      },
      //查询模型：根据需求删除不不要查询条件
      searchModel: {
        ReportCode: "FruProSurvey",
        FillInYear: new Date().getFullYear() + "",
        TimesType: "",
        AreaCode: "",
        Status: "",
        PageNumber: 1,
        PageSize: 20
      },
      pageSizeOpts: [20, 40, 50], //默认分页最大设置
      datas: {}, //table数据对象
      dataIds: [],
      ctx: this, //table数据上下文
      columnsList: [
        //表头对象
        { title: "报表名称", key: "ReportName" },
        //{ title: "填报年度", key: "FillInYear", width: 90 },
        { title: "属行政区划", key: "AreaCodeName", width: 220 },
        //{ title: "填报周期", key: "TimesCycle", width: 90 },
        {
          title: "报表状态",
          key: "StatusName",
          width: 100,
          render: (h, params) => {
            switch (params.row.Status * 1) {
              case 0:
                return h(
                  "span",
                  { style: { color: "#ed3f14" } },
                  params.row.StatusName
                );
              case 1:
                return h(
                  "span",
                  { style: { color: "#ff9900" } },
                  params.row.StatusName
                );
              case 2:
                return h(
                  "span",
                  { style: { color: "#993300" } },
                  params.row.StatusName
                );
              case 3:
                return h(
                  "span",
                  { style: { color: "#2d8cf0" } },
                  params.row.StatusName
                );
              case 4:
                return h(
                  "span",
                  { style: { color: "#19be6b" } },
                  params.row.StatusName
                );
              case 5:
                return h(
                  "span",
                  { style: { color: "#80848f" } },
                  params.row.StatusName
                );
              default:
                return h(
                  "span",
                  { style: { color: "#ff9900" } },
                  params.row.StatusName
                );
            }
          }
        },
        { title: "填报时间", key: "StrUpdateTime", width: 160 },
        {
          title: "操作",
          key: "Id",
          width: 250,
          align: "center",
          render: (h, params) => {
            return h("div", [
              h(
                "Button",
                {
                  class: {
                    ieditColor: true
                  },
                  props: {
                    size: "small",
                    type: "ghost",
                    icon: "ios-paper-outline"
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.ReportYear = params.row.FillInYear;
                      this.AreaCodeName = params.row.AreaCodeName;
                      this.showInfo(params.row.Id, params.row.ReportCode);
                    }
                  }
                },
                "查看"
              ),
              h(
                "Button",
                {
                  class: {
                    ieditColor: true
                  },
                  props: {
                    size: "small",
                    type: "ghost",
                    icon: "network"
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.ReportYear = params.row.FillInYear;
                      this.AreaCodeName = params.row.AreaCodeName;
                      this.editInfo(params.row.Id, params.row.ReportCode);
                    }
                  },
                  attrs: {
                    disabled: params.row.Status == 3 ? false : true
                  }
                },
                "审核"
              ),
              h(
                "Button",
                {
                  class: {
                    ieditColor: true
                  },
                  props: {
                    size: "small",
                    type: "ghost",
                    icon: "ios-undo"
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.unReview(params.row.Id, params.row.ReportCode);
                    }
                  },
                  attrs: {
                    disabled: params.row.Status == 4 ? false : true
                  },
                  directives: [
                    {
                      name: "omg-operation",
                      value: { op: "unreview" }
                    }
                  ]
                },
                "取消审核"
              )
            ]);
          }
        }
      ],
      clientHeight: window.innerHeight - 260 //表格默认高度
    };
  },
  mounted() {
    //table高度计算方法
    const that = this;
    window.onresize = () => {
      return (() => {
        that.clientHeight = window.innerHeight - 260;
      })();
    };
  },
  methods: {
    //初始化行政区划树
    SearchAreaList() {
      var areaCode = this.userInfo.AreaCode;
      // console.log(areaCode);
      var areaList = [];
      if (areaCode != "530000000000" && areaCode != null) {
        var item = this.GetlocaStorage("areatreelist")[0];
        for (var i = 0; i < item.children.length; i++) {
          if (item.children[i].value == areaCode) {
            areaList.push(item.children[i]);
          }
        }
      } else {
        areaList = this.GetlocaStorage("areatreelist");
      }
      this.AreaList = areaList[0].children;
    },
    // //初始化行政区划树
    // SearchAreaList() {
    //     var areaCode = this.userInfo.AreaCode;
    //     if (areaCode != '530000000000') {
    //         var item = this.GetlocaStorage("areatreelist")[0];
    //         for (var i = 0; i < item.children.length; i++) {
    //             if (item.children[i].value == areaCode) {
    //                 this.AreaList.push(item.children[i]);
    //             }
    //         }
    //     } else {
    //         this.AreaList = this.GetlocaStorage("areatreelist");
    //     }
    // },
    // //查询行政区划级联选择
    // SearchCascaderChange(value, selectedData) {
    //     const index = value.length - 1;
    //     this.searchModel.AreaCode = value[index];
    // },
    getTab(name) {
      //console.log(name);
      this.selectTabName = name;
    },
    //查看报表
    showInfo(id, reportCode) {
      var self = this;
      this.$http
        .get("Report", { params: { id: id, reportCode: reportCode } })
        .then(
          //获取数据编辑项的值
          function(res) {
            switch (res.data.list.status) {
              case 1:
                //self.initTab(self, res.data.list.model);
                self.list = res.data.list.model;
                self.ViewShow = true;
                break;
              case 0:
                self.$Modal.error({ title: "提示信息", content: "编辑数据加载失败!!!" });
                break;
              case -1:
                self.$Modal.error({ title: "提示信息", content: "编辑数据加载失败!!!" });
                break;
            }
          }
        );
    },
    //获取当前页码
    getPageNumber(pageIndex) {
      this.searchModel.PageNumber = pageIndex;
      this.initPageData();
    },
    //获取当前分页大小
    getPageSize(pageSize) {
      this.searchModel.PageSize = pageSize;
      this.initPageData();
    },
    initPageData() {
      var areaCode = this.userInfo.AreaCode;
      this.searchModel.AreaCode = areaCode;
      this.getPageData();
    },
    //获取this.datas: {},//table数据对象
    getPageData() {
      var self = this;
      self.$http
        .post("Report/PostReviewPageList", this.searchModel)
        .then(function(res) {
          if (res.data.status === 1) {
            self.datas = res.data;
          } else {
            self.$Modal.error({ title: "提示信息", content: res.data.message });
          }
        });
    },
    //编辑获取对象传入id
    editInfo(id, reportCode) {
      //编辑
      var self = this;
      this.Id = id;
      this.$http
        .get("Report", { params: { id: id, reportCode: reportCode } })
        .then(
          //获取数据编辑项的值
          function(res) {
            switch (res.data.list.status) {
              case 1:
                //self.initTab(self, res.data.list.model);
                self.list = res.data.list.model;
                self.modalShow();
                //self.selectTabName = self.TabTitleList[0].SortCode;
                break;
              case 0:
                self.$Modal.error({ title: "提示信息", content: "编辑数据加载失败!!!" });
                break;
              case -1:
                self.$Modal.error({ title: "提示信息", content: "编辑数据加载失败!!!" });
                break;
            }
          }
        );
    },
    initTab(self, datas) {
      self.TabTitleList = [];
      for (var i = 0; i < datas.length; i++) {
        if (!self.checkTab(datas[i].SortCode, self)) {
          var item = new Object();
          item.SortCode = datas[i].SortCode;
          item.SortName = datas[i].SortName;
          item.list = [];
          for (var j = 0; j < datas.length; j++) {
            if (datas[j].SortCode == datas[i].SortCode) {
              if (!self.checkItem(item.list, datas[j].ItemCode)) {
                item.list.push(datas[j]);
              }
            }
          }
          self.TabTitleList.push(item);
        }
      }
      return self.TabTitleList;
    },
    checkTab(SortCode, self) {
      var res = false;
      for (var i = 0; i < self.TabTitleList.length; i++) {
        if (self.TabTitleList[i].SortCode == SortCode) {
          res = true;
        }
      }
      return res;
    },
    checkItem(datas, ItemCode) {
      var res = false;
      for (var i = 0; i < datas.length; i++) {
        if (datas[i].ItemCode == ItemCode) {
          res = true;
        }
      }
      return res;
    },
    //删除对象
    delInfo(id) {
      var self = this;
      self.$Modal.confirm({
        title: "提示信息",
        content: "<p>数据删除后不可恢复，确定要删除？</p>",
        onOk: () => {
          this.$http
            .delete("GenerateLog", { params: { id: id } })
            .then(function(res) {
              if (res.data.status == 1) {
                self.$Notice.success({ title: "删除成功！", desc: false });
                self.initPageData();
              } else {
                self.$Modal.error({ title: "提示信息", content: "数据删除失败!!!" });
              }
            });
        }
      });
    },
    //省级取消审核
    unReview(id, reportCode) {
      var model = new Object();
      model.Id = id;
      model.reportType = "0";
      model.strMsg = "省级已取消审核!";
      this.save(model);
    },
    //审核
    save(model) {
      var self = this;
      this.$http.post("Report/PostUpStatus", model).then(function(res) {
        if (res.data.status == 1) {
          self.$Notice.success({ title: "审核完成!", desc: false });
          self.getPageData();
          self.strMsg = "";
          self.modalHide();
        } else {
          self.$Modal.error({ title: "提示信息", content: "数据审核失败!!!" });
        }
      });
    },
    saveSure() {
      var model = new Object();
      model.Id = this.Id;
      model.reportType = "4";
      model.strMsg = "";
      this.save(model);
      this.modalHide();
    },
    //审核未通过
    savenUnSure() {
      var self = this;
      this.showAudit = true;
    },
    sureUnSure() {
      this.showAudit = false;
      var model = new Object();
      model.Id = this.Id;
      model.reportType = "0";
      model.strMsg = this.strMsg;
      this.save(model);
    },
    cancelUnSure() {
      this.showAudit = false;
      //this.modalHide();
      this.strMsg = "";
    },
    //数据检测
    checkData(){
     let templist = this.list;
     let isOk = true;//数据无误
     let sumObj = templist[templist.length-1];//合计栏数据
     let totalModel = new Object();
      totalModel.GrandArea = 0;
      totalModel.CumYield = 0;
      //totalModel.AvgMuYield = "";
      totalModel.NewArea = 0;
      totalModel.FOrchard = 0;
      totalModel.FTOrchard = 0;
      totalModel.TOrchard = 0;  
     for(let i = 0;i < templist.length;i++){
       let item  = templist[i];
       let parentModel = new Object();
       parentModel.GrandArea = 0;
       parentModel.CumYield = 0;
       parentModel.NewArea = 0;
       parentModel.FOrchard = 0;
       parentModel.FTOrchard = 0;
       parentModel.TOrchard = 0;  
       parentModel.hasChild = false; 
       for(let j = 0;j < templist.length;j++){
        let sonItem = templist[j];
        if(sonItem.ParentCode == item.VarietyCode){
          parentModel.hasChild = true;
          if(sonItem.GrandArea){
            parentModel.GrandArea += sonItem.GrandArea;
          }
          if(sonItem.CumYield){
            parentModel.CumYield += sonItem.CumYield;
          }
          if(sonItem.NewArea){
            parentModel.NewArea += sonItem.NewArea;
          }
          if(sonItem.FOrchard){
            parentModel.FOrchard += sonItem.FOrchard;
          }
           if(sonItem.FTOrchard){
            parentModel.FTOrchard += sonItem.FTOrchard;
          }
           if(sonItem.TOrchard){
            parentModel.TOrchard += sonItem.TOrchard;
          }
        }
       }
       if(parentModel.hasChild){        
       if(item.GrandArea && parentModel.GrandArea != item.GrandArea){         
         isOk = false;
         return item.Variety+'的全年累计面积不等于其子项之和！';        
       }
       if(item.CumYield && parentModel.CumYield != item.CumYield){
         isOk = false;
         return item.Variety+'的全年累计产量不等于其子项之和！';
       }
       if(item.NewArea && parentModel.NewArea != item.NewArea){
         isOk = false;
         return item.Variety+'的本年新建果园面积不等于其子项之和！';
       }
       if(item.FOrchard && parentModel.FOrchard != item.FOrchard){
         isOk = false;
        return item.Variety+'的树龄5年以下面积不等于其子项之和！';
       }
       if(item.FTOrchard && parentModel.FTOrchard != item.FTOrchard){
         isOk = false;
        return item.Variety+'的树龄5-20年面积不等于其子项之和！';
       } 
       if(item.TOrchard && parentModel.TOrchard != item.TOrchard){
         isOk = false;
        return item.Variety+'的树龄20年以上面积不等于其子项之和！';
       }    
       } 
       if((item.GrandArea - (item.NewArea*1+item.FTOrchard*1+item.FOrchard*1+item.TOrchard*1))<-1||(item.GrandArea - (item.NewArea*1+item.FTOrchard*1+item.FOrchard*1+item.TOrchard*1))>1){
         isOk = false;
         return item.Variety+'的全年累计面积不等于新植面积、树龄5年以下、5-20年、20年以上面积之和！'
       }   
       if(item.VarietyCode !='sum'&& !item.ParentCode){        
         if(item.GrandArea){
           totalModel.GrandArea += item.GrandArea;
         }
         if(item.CumYield){
           totalModel.CumYield += item.CumYield;
         }
         if(item.NewArea){
           totalModel.NewArea += item.NewArea;
         }
         if(item.FOrchard){
           totalModel.FOrchard += item.FOrchard;
         }
         if(item.FTOrchard){
           totalModel.FTOrchard += item.FTOrchard;
         }
         if(item.TOrchard){
           totalModel.TOrchard += item.TOrchard;
         }
       }
     }
     if(sumObj.GrandArea && (totalModel.GrandArea-sumObj.GrandArea < -1||totalModel.GrandArea-sumObj.GrandArea > 1)){       
       isOk = false;
       return '合计栏的全年累计面积计算错误！';
     }
     if(sumObj.CumYield && (totalModel.CumYield-sumObj.CumYield < -1||totalModel.CumYield-sumObj.CumYield >1)){
       isOk = false;
       return '合计栏的全年累计产量计算错误！';
     }
     if(sumObj.NewArea && (totalModel.NewArea-sumObj.NewArea < -1||totalModel.NewArea-sumObj.NewArea >1)){
       isOk = false;
       return '合计栏的新建果园面积计算错误！';
     }
     if(sumObj.FOrchard && (totalModel.FOrchard-sumObj.FOrchard < -1||totalModel.FOrchard-sumObj.FOrchard >1)){
       isOk = false;
       return '合计栏的树龄5年以下面积计算错误！';
     }
     if(sumObj.FTOrchard && (totalModel.FTOrchard-sumObj.FTOrchard <-1||totalModel.FTOrchard-sumObj.FTOrchard >1)){
       isOk = false;
       return '合计栏的树林个5-20年面积计算错误！';
     }
     if(sumObj.TOrchard && (totalModel.TOrchard-sumObj.TOrchard <-1||totalModel.TOrchard-sumObj.TOrchard >1)){
       isOk = false;
       return '合计栏的树龄20年以上面积计算错误！';
     }
     if(isOk){
       return '数据检测无误！';
     }
     return '';
    },
    toAlertCheckResult(){ 
      var message  = this.checkData();   
      this.$Modal.warning({
        title:'提示信息',
        content:message
      });
    },
    //编辑框打开
    modalShow() {
      this.showType = true;
    },
    //编辑框关闭
    modalHide() {
      this.showType = false;
    },
    //取消方法
    cancel() {
      this.showType = false; //关闭modal
      this.TabTitleList = [];
    },
    //重置model
    restModel(modelname) {
      this.$refs[modelname].resetFields(); //重置model
    },
    //全选方法
    selectAll(selection) {
      this.dataIds = selection;
    },
    //checkbox选中方法
    selectSingel(selection, row) {
      this.dataIds = selection;
    },
    //checkbox取消选中方法
    selecChange(selection) {
      this.dataIds = selection;
    },
    //批量删除
    multiSelect() {
      var self = this;
      if (this.dataIds.length !== 0) {
        self.$Modal.confirm({
          title: "提示信息",
          content: "<p>数据删除后不可恢复，确定要删除？</p>",
          onOk: () => {
            var ids = this.getDataIds(this.dataIds);
            this.$http
              .post("GenerateLog/PostBatchDelete", ids)
              .then(function(res) {
                if (res.data.status == 1) {
                  self.dataIds = [];
                  self.$Notice.success({ title: "删除成功！", desc: false });
                  self.initPageData();
                } else {
                  self.$Modal.error({ title: "提示信息", content: "数据删除失败!!!" });
                }
              });
          }
        });
      } else {
        self.$Modal.warning({ title: "提示信息", content: "请选择需要删除的数据!" });
      }
    },
    getDataIds(idList) {
      var ids = [];
      if (idList.length !== 0) {
        for (var i = 0; i < idList.length; i++) {
          ids.push(idList[i].Id);
        }
      }
      return ids;
    },
    currentYear() {
      let year = new Date().getFullYear();
      let month = new Date().getMonth();
      if (month > 1) {
        this.searchModel.FillInYear = year.toString();
      } else {
        this.searchModel.FillInYear = (year - 1).toString();
      }
    }
  },
  //创建Vue页面方法
  created: function() {
    //创业Vue前调用获取this.datas: {},//table数据对象
    this.currentYear();
    this.initPageData();
    this.SearchAreaList();
  },
  watch: {
    //需要监听的在此处新增监听对象
  }
};
</script>
